INCLUDE(CheckCXXCompilerFlag)

MACRO(APPEND_CXX_FLAG_IF_SUPPORTED FLAG VARIABLE)
	UNSET(HAS_FLAG CACHE)
	SET(SAVED_CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET})
	SET(CMAKE_REQUIRED_QUIET YES)
	CHECK_CXX_COMPILER_FLAG(${FLAG} HAS_FLAG)
	SET(CMAKE_REQUIRED_QUIET ${SAVED_CMAKE_REQUIRED_QUIET})
	IF(HAS_FLAG)
		SET(${VARIABLE} "${${VARIABLE}} ${FLAG}")
		MESSAGE(STATUS "Checking for ${FLAG}: yes")
	ELSE(HAS_FLAG)
		MESSAGE(STATUS "Checking for ${FLAG}: no")
	ENDIF(HAS_FLAG)
ENDMACRO(APPEND_CXX_FLAG_IF_SUPPORTED)
